<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>部门管理</title>
    <jsp:include page="../../inc.jsp"></jsp:include>
    <script type="text/javascript">
        var layout_west_tree;
        layout_west_tree_url = getContextPath() + "/deptController/deptList.html";
        var departmentDataGrid;
        var initOptions;
        $(function () {
            parent.$.messager.progress('close');

            initOptions = {
                frozenColumns: [[{
                    title: '编号',
                    width: 150,
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '部门代码',
                        width: 100
                    },
                    {
                        field: 'deptName',
                        title: '部门名称',
                        width: 100
                    },
                    {
                        field: 'status',
                        title: '状态',
                        width: 100
                    },
                    {
                        field: 'deptType',
                        title: '业务单元类型',
                        width: 100
                    }, {
                        field: 'amount',
                        title: '开票限额',
                        width: 100
                    }, {
                        field: 'company',
                        title: '上级业务单元',
                        width: 100
                    }, {
                        field: 'companyNo',
                        title: '上级业务编号',
                        width: 100
                    }
                ]],
                columns: [[{
                    field: 'updateDate',
                    title: '更新日期',
                    width: 100
                }, {
                    field: 'updateName',
                    title: '更新人',
                    width: 100
                }
                ]],
                toolbar: '#toolbar'
            }
            departmentDataGrid = initAjaxDataGrid("/deptController/selectDepts.html", $('#departmentDataGrid'), initOptions);
        });
        function searchFun() {
            initOptions.postData = $.serializeObject($('#searchForm'));
            departmentDataGrid = initAjaxDataGrid("/deptController/selectDepts.html", $('#departmentDataGrid'), initOptions);
            return false;
        }

        function addFunction() {
            addFun("添加部门", "/deptController/deptAdd.html", $('#departmentDataGrid'));
        }

        function editFunction() {
            var select = $('#departmentDataGrid').datagrid('getSelections');
            if (select&&select.length>0) {
                editFun('编辑部门', '/deptController/deptUpdate.html?id=', $('#departmentDataGrid'), {});
            } else {
                parent.$.messager.alert('提示', '请选择一条数据.', 'info');
            }
        }

        function forbiddenFun(title, url, dataGridNode, newOptions) {
            var options = {width: 500, height: 300};
            $.extend(options, newOptions);
            if (options.ids == undefined) {//点击右键菜单才会触发这个
                var rows = dataGridNode.datagrid('getSelections');
                var ids = [];
                ids.push(rows[0].id);
                options.ids = ids;
            } else {//点击操作里面的删除图标会触发这个
                dataGridNode.datagrid('unselectAll').datagrid('uncheckAll');
            }
            parent.$.messager.confirm('询问', title, function (b) {
                if (b) {
                    parent.$.messager.progress({
                        title: '提示',
                        text: '数据处理中，请稍后....'
                    });
                    $.post(getContextPath() + url, {
                        ids: options.ids,
                        status: 1
                    }, function (result) {
                        if (result && isSuccess(result.result)) {
                            dataGridNode.datagrid('getPager').pagination('select');
                            parent.$.messager.alert('提示', result.result + " " + result.message, 'info');
                        }
                        parent.$.messager.progress('close');
                    }, 'JSON');
                }
            });
        }

        function forbiddenFunction() {
            var select = $('#departmentDataGrid').datagrid('getSelections');
            if (select&&select.length>0) {
                deleteFun('您是否要停用当前部门？', '/deptController/disableDept.html', $('#departmentDataGrid'), {});
            } else {
                parent.$.messager.alert('提示', '请选择一条数据.', 'info');
            }
        }

        function deleteFunction() {
            var select = $('#departmentDataGrid').datagrid('getSelections');
            if (select&&select.length>0) {
                deleteFun('您是否要停用当前部门？', '/deptController/deleteDept.html', $('#departmentDataGrid'), {});
            } else {
                parent.$.messager.alert('提示', '请选择一条数据.', 'info');
            }
        }

    </script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center'" title="" style="overflow: hidden;">
        <div class="easyui-layout" data-options="fit:true,border:false">
            <div data-options="region:'north',title:'查询条件',border:false" style="height: 100px; overflow: hidden;">
                <form id="searchForm">
                    <div class="mTop20 mLeft60">
                        <div class="mTop10 line-handsome">
                            <div class="fLeft label-handsome ">
                                <label>部门代码:</label>
                                <input id="sys-employee-gh" name="id" class="easyui-numberbox"
                                       data-options="min:0,precision:0"/>
                            </div>
                            <div class="fLeft label-handsome ">
                                <label>部门名称:</label>
                                <input id="sys-employee-xm" name="deptName" class="easyui-input"/>
                            </div>

                            <div class="fLeft">
                                <a href="javascript:void(0);" class="easyui-linkbutton"
                                   data-options="iconCls:'icon-search'" onclick="searchFun();">搜索</a>
                                <a href="javascript:void(0);" class="easyui-linkbutton"
                                   data-options="iconCls:'brick_delete'" onclick="cleanFun();">清空搜索条件</a>
                            </div>
                        </div>
                        <div class="mTop10 line-handsome">
                        </div>
                    </div>
                </form>
            </div>
            <div data-options="region:'center'" title="" style="overflow: hidden;">
                <table id="departmentDataGrid"></table>
            </div>
        </div>
    </div>
    <div id="toolbar" style="display: none;">
        <%--<c:if test="${fn:contains(sessionInfo.resourceList, '/userController/addPage')}">--%>
        <a onclick="addFunction();" href="javascript:void(0);" class="easyui-linkbutton"
           data-options="plain:true,iconCls:'style_add'">添加</a>
        <%--</c:if>--%>
        <%--<c:if test="${fn:contains(sessionInfo.resourceList, '/userController/editPage')}">--%>
        <a onclick="editFunction();" href="javascript:void(0);" class="easyui-linkbutton"
           data-options="plain:true,iconCls:'style_edit'">编辑</a>
        <%--</c:if>--%>
        <%--<c:if test="${fn:contains(sessionInfo.resourceList, '/userController/batchDelete')}">--%>
        <a onclick="forbiddenFunction();" href="javascript:void(0);" class="easyui-linkbutton"
           data-options="plain:true,iconCls:'style_delete'">停用</a>
        <%--</c:if>--%>
            <%--<a onclick="deleteFunction();" href="javascript:void(0);" class="easyui-linkbutton"--%>
               <%--data-options="plain:true,iconCls:'style_delete'">删除</a>--%>
    </div>

</div>

</body>
</html>
